package com.oracle.service;

import com.oracle.mapper.BookMapper;
import com.oracle.vo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
    @Autowired
    private BookMapper bookMapper;

    public List<Book> queryAllBook(){
        return bookMapper.selectByExample(null);

    }
    public List<Book> queryByExample(Book book){
        return bookMapper.selectByExampleSelective(book);

    }

    public void deleteById(Integer id) {
         bookMapper.deleteByPrimaryKey(id);

    }

    public Book queryBookById(Integer id) {

        return   bookMapper.selectByPrimaryKey(id);
    }

    public void saveBook(Book book) {
        bookMapper.insert(book);

    }

    public void updateBook(Book book) {
         bookMapper.updateByPrimaryKeySelective(book);
    }
}
